﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) 
	{
		txtSearch.Focus();
		this.Page.Form.DefaultButton = btnSearch.UniqueID;
	}

	protected void btnSearch_Click(object sender, EventArgs e)
	{
		string input = txtSearch.Text.Trim();
		if (string.IsNullOrEmpty(input)) return;

		KC.DataAccess.MV6.utils.AddHistory(Master.ip.ID, "User did internal search", input);

		List<string> result = KC.Business.Blog.Search.SearchBlog(input);
		Session["result"] = result;

		rResults.DataSource = result;
		rResults.DataBind();
		
		pnlResults.Visible = true;
		pnlSearch.Visible = false;
	}

	protected void rResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
	{
		if (e.Item == null) return;
		Label lblResult = (Label)e.Item.FindControl("lblResult");
		lblResult.Text = (string)e.Item.DataItem;
	}
}